package com.winning.pmph.utils;

import com.winning.pmph.entity.Task;
import com.winning.pmph.entity.TaskItem;
import org.apache.commons.lang.StringUtils;

public class TaskUtil {
    public static String calCrtOperator(TaskItem taskItem) {
        if (taskItem.getStatus() == TaskItem.STATUS_NOT_COMMIT
                || taskItem.getStatus() == TaskItem.STATUS_REJECT) {
            return taskItem.getEditor();
        }
        else if (taskItem.getStatus() == TaskItem.STATUS_COMMIT
                || taskItem.getStatus() == TaskItem.STATUS_REJECT_2) {
            return taskItem.getFirstAuditor();
        }
        else if (taskItem.getStatus() == TaskItem.STATUS_PASS_1
                || taskItem.getStatus() == TaskItem.STATUS_REJECT_3) {
            return taskItem.getSecondAuditor();
        }
        else if (taskItem.getStatus() == TaskItem.STATUS_PASS_2) {
            return taskItem.getThirdAuditor();
        }
        else if (taskItem.getStatus() == TaskItem.STATUS_PASS
                || taskItem.getStatus() == TaskItem.STATUS_RELEASED) {
            return StringUtils.EMPTY;
        }
        else if (taskItem.getStatus() == TaskItem.STATUS_FINAL_REJECT) {
            if (taskItem.getAuditLevel() == Task.AUDIT_LEVEL_ONE) {
                return taskItem.getFirstAuditor();
            }
            else if (taskItem.getAuditLevel() == Task.AUDIT_LEVEL_TWO) {
                return taskItem.getSecondAuditor();
            }
            else if (taskItem.getAuditLevel() == Task.AUDIT_LEVEL_THREE) {
                return taskItem.getThirdAuditor();
            }
        }
        return StringUtils.EMPTY;
    }
}
